﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WishListCtrl.ascx.cs" Inherits="ShopOnline.Controls.WishListCtrl" %>
<%@ Register Assembly="ShopOnline" Namespace="ShopOnline.Controls" TagPrefix="uc" %>
<script type="text/javascript">
    function addDivider() {
        var count = $('#<%= datalist.ClientID %> .item').length;
        $('#<%= datalist.ClientID %> .item').each(function () {
            var rowcount = Math.floor(count / 3);
            if (count % 3 != 0)
                rowcount++;

            var index = $(this).attr('index');
            if (Math.floor(index / 3) <= rowcount - 2)
                $(this).css('border-bottom', '1px dotted gray');
        });


    }
    
    function btnAddCart_click(id) {
        $('#<%= hidID.ClientID %>').val(id);
        $('#<%= btnAddCart.ClientID %>').click();
    }

    function btnRemoveWishList_click(id) {
        $('#<%= hidID.ClientID %>').val(id);
        $('#<%= btnRemoveWishList.ClientID %>').click();
    }
</script>


<uc:WindowManager ID="windowManager" runat="server" />

<uc:Window ID="gallery" runat="server" URL="Default.aspx" Title="A" WindowWidth="660" WindowHeight="500" AllowResizing="false" AllowScrolling="false" />


<asp:DataList ID="datalist" runat="server">
    <ItemTemplate>
        <li index='<%# index++ %>' class="item" style='width:185px !important; margin:5px 0px 5px 0px !important;'>
            <div class="product-box" style='margin-bottom:5px'>
                <h2 class="product-name" style='height:30px'>
                    <a runat="server" href='<%# string.Format("~/ProductDetails.aspx?{0}=", ShopOnline.BasePage.PRD)  + string.Format("{0}_{1}", ShopOnline.Utilities.GetValidParam(Eval("ProductName").ToString()), Eval("ProductID").ToString()) %>' title='<%# Eval("ProductName") %>'><%# Eval("ProductName") %></a></h2>
                <a runat="server" href='<%# string.Format("~/ProductDetails.aspx?{0}=", ShopOnline.BasePage.PRD)  + string.Format("{0}_{1}", ShopOnline.Utilities.GetValidParam(Eval("ProductName").ToString()), Eval("ProductID").ToString()) %>' title='<%# Eval("ProductName") %>' class="product-image">
                    <asp:Image ID="Image1" runat="server" AlternateText='<%# Eval("ProductName") %>' class="imgThumbnail" 
                            ImageUrl='<%# (Eval("Thumbnail") == DBNull.Value || Eval("Thumbnail").ToString() == "") ? GetDefaultPic() : ShopOnline.Utilities.GetImageUrl((string)Eval("Thumbnail")) %>' />
                </a>
                <div class="price-box">
                    <span class="regular-price" id="product-price-18"><span class="price">
                        <%# SessionUser == null || SessionUser.Price ==  POSSystem.BLL.CustomerType.CustomerPrice.SalePrice ? "$" + Eval("SalePrice").ToString() : (SessionUser.Price ==  POSSystem.BLL.CustomerType.CustomerPrice.DealerPrice ? "$" + Eval("DealerPrice").ToString() : "$" + Eval("PartnerPrice").ToString()) %></span>
                    </span>
                </div>
                <div class="actions">
                    <button type="button" runat="server" onclick='<%# "btnAddCart_click(" +  Eval("ProductID").ToString() + ");" %>' title="Add to Cart" class="button btn-cart">
                        <span><span>Add to Cart</span></span></button>
                    <ul class="add-to-links">
                        <li><a style='cursor:pointer' onclick='<%# "btnRemoveWishList_click(" +  Eval("ProductID").ToString() + ");" %>' class="link-wishlist">Remove from Wishlist</a></li>
                    </ul>
                </div>
            </div>
        </li>
    </ItemTemplate>
</asp:DataList>
<asp:HiddenField ID="hidID" runat="server" />
<asp:Button ID="btnAddCart" runat="server" OnClick="btnAddCart_OnClick" style='display:none' />
<asp:Button ID="btnRemoveWishList" runat="server" OnClick="btnRemoveWishList_OnClick" style='display:none' />